package com.allenjsl.activiti.controller;

import org.activiti.engine.RepositoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;

public class ActivitiController {

    @Autowired
    RepositoryService rep;

    @RequestMapping(value = "/uploadworkflow", method = RequestMethod.POST)
    public String fileupload() {
        try {
            String bpmnFileName = "process/SayHelloToLeave.bpmn";
            rep
                    .createDeployment()
                    .addInputStream(
                            "SayHelloToLeave.bpmn",
                            this.getClass().getClassLoader()
                                    .getResourceAsStream(bpmnFileName)).deploy();


        } catch (Exception e) {
            e.printStackTrace();
        }
        return "index";
    }
}
